package com.piggy.system.api;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import com.piggy.common.core.constant.SecurityConstants;
import com.piggy.common.core.constant.ServiceNameConstants;
import com.piggy.common.core.web.domain.AjaxResult;
import com.piggy.system.api.bo.FlowCompleteBo;
import com.piggy.common.core.domain.R;
import com.piggy.system.api.domain.SysUser;
import com.piggy.system.api.factory.RemoteFlowFallbackFactory;
import com.piggy.system.api.vo.FlowTaskVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * ACT服务
 *
 * @author shark
 */
@FeignClient(contextId = "remoteFlowService", value = ServiceNameConstants.ACT_SERVICE, fallbackFactory = RemoteFlowFallbackFactory.class)
public interface RemoteFlowService {

    @GetMapping("/flow/confirmTheCurrentProcess")
    AjaxResult confirmTheCurrentProcess(@RequestParam("type") Integer type, @RequestParam("orderId") Long orderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/checkNode")
    AjaxResult checkNode(@RequestParam("nodeCheckName") String nodeCheckName, @RequestParam("orderId") Long orderId, @RequestParam("check") boolean check, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/getTask")
    R<Map<String, String>> getTask(@RequestParam("businessKey") String businessKey, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/getTaskByKey")
    R<Map<String, String>> getTaskByKey(@RequestParam("processDefinitionKey") String processDefinitionKey, @RequestParam("businessKey") String businessKey, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/getTaskSingResult")
    R<String> getTaskSingResult(@RequestParam("businessKey") String businessKey, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/getAssignees")
    R<List<SysUser>> getAssignees(@RequestParam("key") String key, @RequestParam("orderId") Long orderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/createMainProcess")
    R<Map<String, Object>> createMainProcess(@RequestParam("orderId") Long orderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @PostMapping("/flow/getFlowInstance")
    R getFlowInstance(@RequestBody Map<String, Object> map, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/flow/complete")
    R complete(@RequestBody FlowCompleteBo bo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/queryCurrProcess")
    R<List<JSONObject>> queryCurrProcess(@RequestParam("key") String key, @RequestParam("orderId") Long orderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/getTaskListByBusinessKey")
    R<List<JSONObject>> getTaskListByBusinessKey(@RequestParam("processKeyForeclosure") String processKeyForeclosure, @RequestParam("valueOf") String valueOf,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/createHistoricTaskInstanceQuery")
    R<List<Map<String, Object>>> createHistoricTaskInstanceQuery(@RequestParam("orderId") Long orderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/abPreliminaryReviewFailed")
    R<Boolean> abPreliminaryReviewFailed(@RequestParam("processKey2") String processKey2, @RequestParam("valueOf") String valueOf, @RequestParam("aBpreliminaryReviewFailed") String aBpreliminaryReviewFailed, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/removeVariables")
    R removeVariables(@RequestParam("taskId") String taskId, @RequestParam("removeList") List<String> removeList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/removeVariable")
    R removeVariable(@RequestParam("taskId") String taskId, @RequestParam("i") String i, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/getVariable")
    R<Boolean> getVariable(@RequestParam("taskId") String taskId, @RequestParam("reviewMode") String reviewMode, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/cleanVariable")
    R cleanVariable(@RequestParam("orderId") String orderId, @RequestParam("processKey") String processKey, @RequestParam("removeList") List<String> removeList, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/isCompleteApproval")
    R<Boolean> isCompleteApproval(@RequestParam("orderId") String orderId, @RequestParam("finalAssignee") Integer finalAssignee, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/getTaskListByKey")
    R<List<JSONObject>> getTaskListByKey(@RequestParam("orderId") String orderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/isPresent")
    R<Boolean> isPresent(@RequestParam("processKey") String processKey, @RequestParam("businessKey") String businessKey, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/flow/getTaskVoByBusinessKey")
    R<List<FlowTaskVo>> getTaskVoByBusinessKey(@RequestParam("businessKey") String businessKey, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
